<template>
  <div>
    <div class="item_title">非工作时间用电统计（单位:小时）</div>
    <div style="width: 100%; height: 280px">
      <div class="newDangerHead">
        <div style="width: 40%">网点名称</div>
        <div style="width: 30%">累计时长</div>
        <div style="width: 15%">最大时长</div>
        <div style="width: 15%">平均时长</div>
      </div>
      <div @click="noworkelectricityShow($event)">
        <vue-seamless-scroll
          :class-option="defaultOption"
          :data="noWorkElectricityList"
          class="newWangerBox"
        >
          <div
            class="newWangerItem"
            v-for="(item, index) in noWorkElectricityList"
            :key="index"
            style="cursor: pointer"
           :data-branchid="item.branchId" 
          >
            <div style="width: 40%">{{ item.branchName }}</div>
            <div style="width: 30%">{{ item.totalNonworkHour }}</div>
            <div style="width: 15%">{{ item.maxNonworkHour }}</div>
            <div style="width: 15%">{{ item.avgNonworkHour }}</div>
          </div>
        </vue-seamless-scroll>
      </div>
    </div>
  </div>
</template>
<script>
import ajax from "@/utils/ajax";
import vueSeamlessScroll from "vue-seamless-scroll";
export default {
  data() {
    return {
      noWorkElectricityList: [
        {
          addres: "丰泽新秀社区",
          cumulative: "3002",
          max: "4",
          ave: "2.7",
        },
        {
          addres: "泉州银行泉秀支行",
          cumulative: "1910",
          max: "3",
          ave: "1.7",
        },
        {
          addres: "泉州大洋百货",
          cumulative: "3124",
          max: "5",
          ave: "2.9",
        },
        {
          addres: "泉州凤凰百货",
          cumulative: "3412",
          max: "9",
          ave: "4.9",
        },
        {
          addres: "幸福大厦",
          cumulative: "1111",
          max: "16",
          ave: "38",
        },
        {
          addres: "中心客运站",
          cumulative: "5201",
          max: "21",
          ave: "15",
        },
      ],
    };
  },
  components: {
    vueSeamlessScroll,
  },
  computed: {
    defaultOption() {
      return {
        step: 0.2, // 数值越大速度滚动越快
      };
    },
  },
  mounted() {
    this.getNonworkEnergyUsedStatistics();
  },
  methods: {
     getNonworkEnergyUsedStatistics() {
      ajax.get({
        url: this.$API.getNonworkEnergyUsedStatistics,
        data: {},
        success: (response) => {
          let self = this;
          self.noWorkElectricityList = response.data;
        },
      });
    },
    noworkelectricityShow(e) {
      let branchid
      if(e.target.parentNode.dataset.branchid !=undefined)
      {
        branchid =  e.target.parentNode.dataset.branchid
      }
      else{
        branchid = e.target.dataset.branchid
      }
    
      let self = this;
      self.$emit("noworkelectricityShow", "third", branchid);
    },
  },
};
</script>
<style scoped>
* {
  box-sizing: border-box;
}
.item_title {
  height: 50px;
  padding: 15px;
  color: #ffffff;
  font-size: 18px;
  font-weight: 600;
  border-bottom: 1px solid #488fff47;
}
.newDangerHead {
  display: flex;
  line-height: 20px;
  padding: 10px 5px;
  color: #ffffff;
  justify-content: space-around;
  text-align: center;
  border-bottom: 1px solid #488fff47;
}
.newWangerItem {
 
  width: 100%;
  display: flex;
  justify-content: space-between;
  border-radius: 3px;
  color: #ffffff;
  text-align: center;
  padding: 8px 5px;
}
.newWangerBox {
  margin-top: 10px;
  height: 220px;
  overflow: hidden;
}
</style>